home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / hsclib / attrib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  6.0 KB  |  160 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1995-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. /*
  21.  * hsclib/attribute.h
  22.  *
  23.  * attribute structure and funcs for hsc
  24.  */
  25.  
  26. #ifndef HSC_ATTRIBUTE_H
  27. #define HSC_ATTRIBUTE_H
  28.  
  29. /* variable types */
  30. #define VT_NONE   0             /* no type; only after init */
  31. #define VT_URI    1             /* uri */
  32. #define VT_STRING 2             /* text string */
  33. #define VT_BOOL   3             /* boolean */
  34. #define VT_NUM    4             /* TODO: numeric */
  35. #define VT_ENUM   5             /* enumerator */
  36. #define VT_ID     6             /* TODO: id (name reference) */
  37. #define VT_COLOR  7             /* TODO: jerk's color */
  38.  
  39. #define VT_STR_URI    "URI"     /* uri */
  40. #define VT_STR_STRING "STRING"  /* text string */
  41. #define VT_STR_BOOL   "BOOL"    /* boolean */
  42. #define VT_STR_NUM    "NUM"     /* numeric */
  43. #define VT_STR_ENUM   "ENUM"    /* enumerator */
  44. #define VT_STR_ID     "ID"      /* id (name reference) */
  45. #define VT_STR_COLOR  "COLOR"   /* color */
  46.  
  47. /* variable flags */
  48. #define VF_ONLYONCE     (1<<0)  /* attribute may occure only once */
  49. #define VF_REQUIRED     (1<<1)  /* attribute is required */
  50. #define VF_CONST        (1<<2)  /* attribute is read-only: <$DEFINE> */
  51. #define VF_JERK         (1<<3)  /* attribute only used by jerks */
  52. #define VF_STRIPEXT     (1<<4)  /* URI: strip tag, if external */
  53. #define VF_GETSIZE      (1<<5)  /* URI: get WIDTH & HEIGHT from here */
  54. #define VF_RECOMMENDED  (1<<6)  /* attribute is recommended to appear */
  55.  
  56. #define VF_KEEP_QUOTES  (1<<28) /* keep quotes untouched */
  57. #define VF_GLOBAL       (1<<29) /* attribute is global: <$DEFINE> */
  58. #define VF_MACRO        (1<<30) /* macro-attr */
  59. #define VF_TAG          (1<<31) /* tag-attr (see note below) */
  60.  
  61. /*
  62.  * NOTE on VF_TAG:
  63.  *
  64.  * Within uri-attributes, there is one problem: if you pass
  65.  * an uri-attr to a macro or <$define>, the uri is parsed twice,
  66.  * when attribute is passed to tag.
  67.  * This produces shit when the uri is parsed the second time
  68.  * (eg absolute uri is converted again)
  69.  *
  70.  * Therefor, uris are only parsed, if the VF_TAG-flag is
  71.  * enabled. By default, VF_TAG is disabled and can only be
  72.  * enabled when copying local macro attribute to the global
  73.  * attribute list. (see "copy_local_varlist()" in "attrib.c")
  74.  */
  75.  
  76. #define VF_CONST_STR       "CONST" /* attr is read only <$DEFINE> */
  77. #define VF_CONST_SHT       "C"
  78. #define VF_GLOBAL_STR      "GLOBAL"        /* global attribute <$DEFINE> */
  79. #define VF_GLOBAL_SHT      "G"
  80. #define VF_JERK_STR        "JERK"  /* attr only used by jerks */
  81. #define VF_JERK_SHT        "J"
  82. #define VF_ONLYONCE_STR    "ONLYONCE"      /* attr may appear only once in tag */
  83. #define VF_ONLYONCE_SHT    "1"
  84. #define VF_REQUIRED_STR    "REQUIRED"      /* attr is required */
  85. #define VF_REQUIRED_SHT    "R"
  86. #define VF_STRIPEXT_STR    "STRIPEXT"      /* strip tag, if URI is external */
  87. #define VF_STRIPEXT_SHT    "X"
  88. #define VF_GETSIZE_STR     "GETSIZE"       /* follow URI to get WIDTH & HEIGHT */
  89. #define VF_GETSIZE_SHT     "Z"
  90. #define VF_RECOMMENDED_STR "RECOMMENDED"       /* follow URI to get WIDTH & HEIGHT */
  91. #define VF_RECOMMENDED_SHT "RCMD"
  92.  
  93. /* prefix for temporary attributes */
  94. #define PREFIX_HSCATTR "HSC."
  95. #define PREFIX_TMPATTR "HSC.TMP."
  96.  
  97. /* chars that act like opening/closing quote */
  98. #define VQ_STR_QUOTE "\"'"
  99.  
  100. /* "no quote" value for quote in HSCATTR */
  101. #define VQ_NO_QUOTE 0
  102.  
  103. /* error return value for set_macro_args() to set var->macro_id with */
  104. #define MCI_GLOBAL  0           /* indicate global attributes */
  105. #define MCI_ERROR   0xffffffff
  106. #define MCI_APPCTAG 0xfffffffe  /* used by app_ctag(); see "tag.c" */
  107.  
  108. /* attribute structure */
  109. typedef struct hscvar
  110. {
  111.     STRPTR name;                /* macro id */
  112.     STRPTR deftext;             /* deftext text */
  113.     STRPTR text;                /* text to be expanded to */
  114.     STRPTR enumstr;             /* enumerator string */
  115.     ULONG macro_id;             /* macro-call-id for local var */
  116.     ULONG varflag;              /* flags; see VF_xx */
  117.     int quote;                  /* quote char */
  118.     BYTE vartype;               /* type; see VT_xx */
  119. }
  120. HSCATTR;
  121.  
  122. #define HSCVAR HSCATTR          /* TODO: remove */
  123.  
  124. /*
  125.  * global funcs
  126.  */
  127. #ifndef NOEXTERN_HSCLIB_VARS_H
  128.  
  129. extern VOID prt_varlist(DLLIST * varlist, STRPTR title);
  130.  
  131. extern HSCATTR *new_hscattr(STRPTR newname);
  132. extern VOID del_hscattr(APTR data);
  133. extern HSCATTR *cpy_hscattr(HSCATTR * oldvar);
  134.  
  135. extern DLNODE *find_attrnode(DLLIST * varlist, STRPTR name);
  136. extern HSCATTR *find_varname(DLLIST * varlist, STRPTR name);
  137. extern HSCATTR *app_var(DLLIST * varlist, STRPTR newname);
  138.  
  139. extern BOOL check_enumstr(HSCATTR * var, STRPTR value, INFILE * inpf);
  140.  
  141. extern STRPTR set_vartext(HSCATTR * var, STRPTR newtext);
  142. extern BOOL set_varbool(HSCATTR * attr, BOOL value);
  143. extern BOOL clr_vartext(HSCATTR * var);
  144. extern VOID clr_attrdef(HSCATTR * attr);
  145. extern BOOL clr_varlist(DLLIST * varlist);
  146. extern VOID clr_varlist_bool(DLLIST * varlist);
  147.  
  148. extern STRPTR get_vartext_byname(DLLIST * varlist, STRPTR name);
  149. extern STRPTR get_vartext(HSCATTR * var);
  150. extern BOOL get_varbool_byname(DLLIST * varlist, STRPTR name);
  151. extern BOOL get_varbool(HSCATTR * attr);
  152. extern LONG get_varnum(HSCATTR * attr);
  153. extern LONG get_varnum_byname(DLLIST * varlist, STRPTR name);
  154.  
  155. extern STRPTR get_vardeftext(HSCATTR * var);
  156.  
  157. #endif /* NOEXTERN_HSCLIB_ATTRIBUTE_H */
  158. #endif /* HSCLIB_ATTRIBUTE_H */
  159.  
  160.